package mainWindowSupport;

/*
 *  ____  _____ ____  ____  _____ ____ ___    _  _____ _____ ____  
 * |  _ \| ____|  _ \|  _ \| ____/ ___|_ _|  / \|_   _| ____|  _ \ 
 * | | | |  _| | |_) | |_) |  _|| |    | |  / _ \ | | |  _| | | | |
 * | |_| | |___|  __/|  _ <| |__| |___ | | / ___ \| | | |___| |_| |
 * |____/|_____|_|   |_| \_\_____\____|___/_/   \_\_| |_____|____/ 
 * 
 */

import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import actionHandlers.*;

public class MenuBar extends JMenuBar{
	
	private static final long serialVersionUID = -4782458751245269960L;

	public MenuBar()
	{
		super();
		//Create the File menu: submenus-> New, Open, Save, Quit
		JMenu fileItem = new JMenu("File");
		JMenuItem newItem = new JMenuItem("New");
		fileItem.add(newItem);
		newItem.addActionListener(new NewListener());
		JMenuItem openItem = new JMenuItem("Open");
		fileItem.add(openItem);
		JMenuItem saveItem = new JMenuItem("Save");
		saveItem.addActionListener(new SaveHandler());
		fileItem.add(saveItem);
		JMenuItem quitItem = new JMenuItem("Quit");
		fileItem.add(quitItem);
		
		
		//Create the Edit Menu: submenus -> Copy, Paste, Preferences
		JMenu editItem = new JMenu("Edit");
		JMenuItem copyItem = new JMenuItem("Copy");
		editItem.add(copyItem);
		JMenuItem pasteItem = new JMenuItem("Paste");
		editItem.add(pasteItem);
		JMenuItem preferencesItem = new JMenuItem("Preferences");
		editItem.add(preferencesItem);
		
		//Create the Tools menu: submenus-> Build
		JMenu toolsItem = new JMenu("Tools");
		JMenuItem buildItem = new JMenuItem("Build");
		toolsItem.add(buildItem);
		quitItem.addActionListener(new CloseHandler());
		openItem.addActionListener(new OpenHandler());
		
		//Add main menus to Menu Bar
		this.add(fileItem);
		this.add(editItem);
		this.add(toolsItem);
	}
}

/*
 * static final private String QUIT = "quit";
	static final private String SAVE = "save";
	static final private String BUILD = "build";
	private static final long serialVersionUID = -2303006344184845201L;

	public mainWindow()
	{
		JMenuItem item = null;
		
		//Create the menu bar and panel
		JMenuBar topMenu = new JMenuBar();
		JPanel drawArea = new JPanel(new BorderLayout());
		drawArea.setPreferredSize(new Dimension(800,600));
		drawArea.setBorder(BorderFactory.createEtchedBorder());
		
		//Create the file menu: submenus->quit and save
		JMenu fileItem = new JMenu("File");
		item = makeMenuItem("Save",SAVE);
		fileItem.add(item);
		item = makeMenuItem("Quit",QUIT);
		fileItem.add(item);
			
		//Create the tools menu: submenus->build
		JMenu toolsItem = new JMenu("Tools");
		item = makeMenuItem("Build a New Menu",BUILD);
		toolsItem.add(item);
		
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		//Combine all menus into menu bar
		topMenu.add(fileItem);		
		topMenu.add(toolsItem);
		
		//Create the toolbar
		toolBar mainBar = new toolBar();
		
		this.add(mainBar, BorderLayout.PAGE_START);
		this.add(drawArea, BorderLayout.CENTER);
		
		//Put menu bar into frame and set frame size
		this.setJMenuBar(topMenu);
		this.setBounds(100,50,800,600);
	}
	
	private JMenuItem makeMenuItem(String menuName, String actionCommand) {
		
		//Creates a menu item
		JMenuItem item = new JMenuItem(menuName);
		item.setActionCommand(actionCommand);
		item.addActionListener(this);
		
		return item;
	}
	
	public void run()
	{
		this.setVisible(true);
	}

	public void actionPerformed(ActionEvent e) {
		
		String cmd = e.getActionCommand();
		
		//Controls action handler for menu items
		if (QUIT.equals(cmd)) {
			System.exit(0);
		}
		if (SAVE.equals(cmd)) {
			//TODO
		}
		if (BUILD.equals(cmd)) {
			menuWizard builder = new menuWizard();
			builder.run();
		}
		
	}
}

*/
